#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <cassert>
using namespace std;
inline int Cn2(int n)
{
    return n*(n-1)/2;
}
//m:width
//n:height
int rectangle(int M, int N, int K)
{
    int min_n, min_m;
    min_n = (K-1)/M + 1;
    min_m = (K-1)/N + 1;
    int rt = 0;
    for (int i=min_m;i<=M;i++) {
        for (int j=min_n;j<=N;j++){
            for (int k=1;k<=j&&k*i<=K;k++){
                int l;
                if (j==k)
                    l = 0;
                else
                    l = (K - i*k)/(j-k);
                if(l>=i)
                    continue;
                if(l*(j-k) == K-i*k){
                    int t = Cn2(i)*Cn2(k) + Cn2(j-k)*Cn2(l) + Cn2(l)*k*(j-k);
                    rt = max(rt,t);
                }
            }
        }
    }
    return rt;
}
int main()
{
    //cout<<rectangle(3,3,8)<<endl;
    //cout<<rectangle(4,5,13)<<endl;
    //cout<<rectangle(7,14,86)<<endl;
    int T,N,M,K;
    cin>>T;
    for (int i = 1; i <= T; ++i) {
        cin>>N>>M>>K;
        int rt = rectangle(M,N,K);
        cout<<"Case #"<<i<<": "<<rt;
        if(i != T)
            cout<<endl;
    }
}
